<!DOCTYPE html>
<html th:replace="layout/layout"
      xmlns:th="http://www.thymeleaf.org">
    <title th:fragment="titleName">菜单管理</title>
    <style th:fragment="styles">
        #nestable2 .dd-item > .dd-demo::before {
            content: "编辑";
            width: 40px;
            height: 30px;
            line-height: 30px;
            top: -0px;
            border-radius: 2px;
            font-weight: bold;
            color: rgb(103, 106, 108);
        }

        #nestable2 .dd-item > .dd-demo1::before {
            content: "删除";
            width: 40px;
            height: 30px;
            line-height: 30px;
            top: -0px;
            border-radius: 2px;
            font-weight: bold;
            color: red;
        }

        button.dd-demo {
            position: absolute;
            top: 0px;
            right: 20px;
        }

        button.dd-demo1 {
            position: absolute;
            top: 0px;
            right: 2px;
        }

        input.checks {
            position: absolute;
            top: 0px;
            right: 100px;
            margin-top: 15px
        }
    </style>
    <div id="customModule" th:fragment="content">
        <div class="row wrapper border-bottom white-bg page-heading">
            <div class="col-lg-10">
                <h2>菜单管理</h2>
                <ol class="breadcrumb">
                    <li>
                        <a href="/index">首页</a>
                    </li>
                    <li>
                        <a>权限管理</a>
                    </li>
                    <li class="active">
                        <strong>菜单管理</strong>
                    </li>
                </ol>
            </div>
            <div class="col-lg-2">

            </div>
        </div>
        <div class="wrapper wrapper-content  animated fadeInRight">
            <div class="row">
                <div class="col-lg-4">
                    <div id="nestable-menu">
                        <button class="btn btn-white btn-sm" data-action="expand-all" type="button">展开</button>
                        <button class="btn btn-white btn-sm" data-action="collapse-all" type="button">收起</button>
                    </div>
                </div>
                <div class="col-lg-4">
                    <div class="form-group">
                        <select @change="selectChanged" class="form-control" v-model="roleChecked">
                            <option :value="item.id" v-for="(item,index) in roleList">
                                {{item.name}}
                            </option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-4">
                    <div class="ibox ">
                        <div class="ibox-title">
                            <h5>列表</h5>
                        </div>
                        <div class="ibox-content">
                            <p class="m-b-lg">
                                <strong>说明:</strong>
                                通过拖动菜单完成关系的修改，最后点击下方的提交按钮。
                            </p>
                            <div class="dd" id="nestable2">
                                <ol class="dd-list">
                                    <li :data-id="menuItem.id" :key="index" class="dd-item"
                                        v-for="(menuItem,index) in menu"
                                        v-if="menuItem.level == 1">
                                        <button data-action="collapse" type="button" v-if="menuItem.children.length">
                                            Collapse
                                        </button>
                                        <button data-action="expand" style="display: none;" type="button"
                                                v-if="menuItem.children.length">Expand
                                        </button>
                                        <div class="dd-handle">{{menuItem.textCH}}</div>
                                        <button @click="menuClick(menuItem)" class="dd-demo"></button>

                                        <ol class="dd-list" v-if="menuItem.children.length">
                                            <li :data-id="subMenuItem.id" class="dd-item"
                                                v-for="(subMenuItem,subIndex) in menuItem.children">
                                                <div class="dd-handle">{{subMenuItem.textCH}}</div>
                                                <button @click="menuClick(subMenuItem)" class="dd-demo"></button>
                                            </li>
                                        </ol>
                                    </li>
                                </ol>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="row">
                                <div class="col-lg-3 col-lg-2">
                                    <button @click="submitMenu()" class="ladda-button ladda-button-demo btn btn-primary"
                                            v-if="roleID==1||roleID==2"
                                            data-style="zoom-in" id="submitMenu">
                                        <span class="ladda-label">提交</span>
                                        <span class="ladda-spinner"></span>
                                    </button>
                                </div>
                                <div class="col-lg-9">
                                    <button @click="submitCancel()" v-if="roleID==1||roleID==2"
                                            class="ladda-button ladda-button-demo btn btn-white" data-style="zoom-in"
                                            id="cancelMenu">
                                        <span class="ladda-label">取消</span>
                                        <span class="ladda-spinner"></span>
                                    </button>
                                    <textarea class="form-control" id="nestable-output"
                                              style="display: none"></textarea>
                                </div>
                            </div>


                        </div>
                    </div>
                </div>
                <div class="col-lg-8">
                    <div class="ibox ">
                        <div class="ibox-title">
                            <h5>编辑</h5>
                        </div>
                        <div class="ibox-content">
                            <form class="form-horizontal">
                                <p>{{choiceMenuName}}</p>

                                <div class="form-group">
                                    <label class="col-lg-2 control-label">菜单编号</label>
                                    <div class="col-lg-10">
                                        <input class="form-control" disabled="" type="text" v-model="menuNo">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-lg-2 control-label">菜单名称</label>
                                    <div class="col-lg-10">
                                        <input class="form-control" type="text" v-model="menuName">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-lg-2 control-label">菜单路由</label>
                                    <div class="col-lg-10">
                                        <input class="form-control" type="text" v-model="menuUrl">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-lg-2 control-label">菜单级别</label>
                                    <div class="col-lg-10">
                                        <input class="form-control" disabled="" type="text" v-model="menuLevel">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-lg-2 control-label">菜单顺序</label>
                                    <div class="col-lg-10">
                                        <input class="form-control" disabled="" type="text" v-model="orderID">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-lg-2 control-label">菜单图标</label>
                                    <div class="col-lg-10">
                                        <input class="form-control" disabled="" type="text" v-model="imageUrl">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-lg-2 control-label">菜单逻辑KEY</label>
                                    <div class="col-lg-10">
                                        <input class="form-control" disabled="" type="text" v-model="keyName">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-lg-2 control-label">菜单父节点</label>
                                    <div class="col-lg-10">
                                        <input class="form-control" disabled="" type="text" v-model="parentID">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-lg-2 control-label">是否可见</label>

                                    <div class="col-lg-10">
                                        <div class="onoffswitch" style="top: 5px">
                                            <input class="onoffswitch-checkbox" id="example1" v-model="activity"
                                                   type="checkbox">
                                            <label class="onoffswitch-label" for="example1">
                                                <span class="onoffswitch-inner"></span>
                                                <span class="onoffswitch-switch"></span>
                                            </label>
                                        </div>
                                    </div>
                                </div>
                                <div>
                                    <div :key="index" class="form-group" v-for="(item,index) in funList">
                                        <label class="col-lg-2 control-label">允许{{item.buttonDescription}}</label>
                                        <div class="col-lg-10">
                                            <div class="onoffswitch" style="top: 5px">
                                                <input :id="item.enDesc" class="onoffswitch-checkbox" type="checkbox"
                                                       v-model="item.activity">
                                                <label :for="item.enDesc" class="onoffswitch-label">
                                                    <span class="onoffswitch-inner"></span>
                                                    <span class="onoffswitch-switch"></span>
                                                </label>
                                            </div>
                                        </div>

                                    </div>
                                </div>

                                <div class="hr-line-dashed"></div>
                                <div class="form-group" style="top: 10px;">
                                    <div class="col-lg-3 col-lg-2" style="text-align: right">
                                        <button @click="rightSubmit()"
                                                class="ladda-button ladda-button-demo btn btn-primary"
                                                data-style="zoom-in" id="submitMenu1">
                                            <span class="ladda-label">提交</span>
                                            <span class="ladda-spinner"></span>
                                        </button>
                                    </div>
                                    <div class="col-lg-9">
                                        <button @click="submitRightCancel()"
                                                class="ladda-button ladda-button-demo btn btn-white"
                                                data-style="zoom-in">
                                            <span class="ladda-label">取消</span>
                                            <span class="ladda-spinner"></span>
                                        </button>
                                    </div>
                                </div>
                            </form>


                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div th:fragment="scriptRef">
        <script th:src="@{/js/menu/menu.js}"></script>
        <script th:src="@{/js/lib/inspinia/js/plugins/nestable/jquery.nestable.js}"></script>
        <script th:src="@{/js/lib/inspinia/js/plugins/ladda/spin.min.js}"></script>
        <script th:src="@{/js/lib/inspinia/js/plugins/ladda/ladda.min.js}"></script>
        <script th:src="@{/js/lib/inspinia/js/plugins/ladda/ladda.jquery.min.js}"></script>
    </div>

    <script th:fragment="scripts" type="text/javascript">
        Menu.init();
    </script>
</html>